"use strict";
//定义一个数值和字符串的联合类型
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
exports.__esModule = true;
var str = "str";
//定义一个类型断言
var someValue = "this is a";
var setValue = someValue.length;
console.log(setValue);
//定义一个 void 实现函数的无返回值
function setSum() {
    console.log("收到就好");
}
//定义一个 never 的函数
function nevers() {
    return Error("never的函数");
}
//分别定义 es5 和 ts 的函数定义
var Protype = /** @class */ (function () {
    function Protype(name, age) {
        this.name = name;
        this.age = age;
    }
    Protype.prototype.say = function () {
        console.log("111");
    };
    return Protype;
}());
var p = new Protype("小", 12);
p.say();
//定义函数时， 分别实现参数类型、剩余参数、默认参数
//参数类型
function aa(name, age) {
    console.log(name, age);
}
aa("小", 12);
//剩余参数
function aa1(name) {
    var age = [];
    for (var _i = 1; _i < arguments.length; _i++) {
        age[_i - 1] = arguments[_i];
    }
    console.log(name, age);
}
aa1("小", 12, 1, 2, 3);
//默认参数
function aa2(name, age) {
    if (age === void 0) { age = 10; }
    console.log(name, age);
}
aa2("小");
function ff(name, age) {
    return name + age;
}
console.log(ff("12", "5254"));
//在 ts 中定义一个类并实现继承
var Protype1 = /** @class */ (function () {
    function Protype1(name, sum) {
        this.name = name;
        this.sum = sum;
    }
    Protype1.prototype.strs = function () {
        console.log("21");
        this.ect();
        this.est();
    };
    Protype1.prototype.ect = function () {
        console.log("202");
    };
    Protype1.prototype.est = function () {
        console.log("333");
    };
    return Protype1;
}());
var Protype1son = /** @class */ (function (_super) {
    __extends(Protype1son, _super);
    function Protype1son(name, sum) {
        var _this = _super.call(this, name, sum) || this;
        _this.est();
        return _this;
    }
    return Protype1son;
}(Protype1));
//父实例
var fs = new Protype1("12", 263);
fs.strs();
//继承的实例
var es = new Protype1("55", 235);
es.strs();
var sets = {
    aa: "23",
    bb: 65,
    2: "gsjd",
    3: "husd"
};
//Ts定义一个求和函数;例Add(2,8,9,6,5,8,7),返回结果45
function Add() {
    var arr = [];
    for (var _i = 0; _i < arguments.length; _i++) {
        arr[_i] = arguments[_i];
    }
    var newarr = arr.reduce(function (a, b) {
        return a + b;
    });
    return newarr;
}
console.log(Add(2, 8, 9, 6, 5, 8, 7)); //45
//Ts定义一个函数返回值为boolean类型的判断函数;例isTrue(nudefined),返回false
// function IsTrue(nud:boolean):boolean{
//      return nud
// }
// console.log(IsTrue(undefined));
//数字（乘5）添加：
var arrs = ["a", "c", 6, "e", 5, 3, "d"];
function wuwu(arr6) {
    var arr5 = [];
    arr6.forEach(function (item) {
        if (typeof (item) == "number") {
            arr5.push(item * 5);
        }
    });
    return arr5;
}
console.log(wuwu(arrs));
